home *** CD-ROM | disk | FTP | other *** search
/ PC World 2008 September / PCWorld_2008-09_cd.bin / v cisle / sadanastroju / IE7proSetup_2.3.exe / plugins / serverinfo / plugin.js
Text File  |  2008-05-13  |  4KB  |  127 lines

  1. // ==UserScript==
  2. // @name          Server Info
  3. // @namespace     http://iescripts.org
  4. // @description      Display the Websites IP Address, Web Server and last modified time
  5. // @statussize    84
  6. // ==/UserScript==
  7.  
  8. (function()
  9. {
  10.     var plugin = PRO_plugin(@name);
  11.     plugin.onpagechange = handlePageChange;
  12.     plugin.registerContextMenu("Site uptime/WebServer", menuShowNetcraft);
  13.     plugin.registerContextMenu("Domain Name Owner", menuShowDNSOwner);
  14.     plugin.registerContextMenu("Server Location", menuShowServerLocation);
  15.     
  16.     
  17.     var gTabId = "";
  18.     var gFindIP = "";
  19.     var gFindServer = "";
  20.     /*
  21.     var reqObj = new Object();
  22.     reqObj.request = function(callback, tabId, url, userAgent, lastModify,qtype) {
  23.         var req;
  24.         req = PRO_xmlhttpRequest();
  25.         req.onreadystatechange = function() {
  26.             if (req.readyState == 4) {// completed
  27.                 if (req.status < 400) {// only if "OK"
  28.                     try {
  29.                         callback(req, tabId);
  30.                     } catch(err) {
  31.                     }
  32.                 } else {
  33.                     // PRO_log("There was a problem loading data :\n" + req.status+ "/" + req.statusText);
  34.                 }
  35.                 setTimeout(function() {req.forceClean();req = null;}, 1000);
  36.             }
  37.         }
  38.         try {
  39.             req.open(qtype, url);
  40.             req.setRequestHeader( "User-Agent", userAgent);
  41.             if(lastModify.length > 0)
  42.                 req.setRequestHeader( "If-Modified-Since", lastModify);
  43.             req.send(null);
  44.         
  45.         } catch(err){ 
  46.         }
  47.         return req;
  48.     }*/
  49.  
  50.     // escape the url
  51.     function encodeURL(url)
  52.     {
  53.         return escape(url).replace(/\+/g, '%2B').replace(/\"/g, '%22').replace(/\'/g, '%27');
  54.     }
  55.     
  56.     function menuShowNetcraft(tabId,url) {
  57.         var urlhost = url.split("/");
  58.         var qhost = urlhost[2];
  59.         PRO_openInTab("http://uptime.netcraft.com/up/graph/?host="+qhost,1);
  60.     }
  61.  
  62.     function menuShowDNSOwner(tabId,url) {
  63.         var urlhost = url.split("/");
  64.         var qhost = urlhost[2];
  65.         PRO_openInTab("http://www.dnsstuff.com/tools/whois.ch?ip="+qhost+"&src=ShowIP",1);
  66.     }
  67.  
  68.     function menuShowServerLocation(tabId,url) {
  69.         var urlhost = url.split("/");
  70.         var qhost = urlhost[2];
  71.         PRO_openInTab("http://ip2country.esymbian.info/?host="+qhost,1);
  72.     }
  73.  
  74.     function handlePageChange(tabId, url, state) {
  75.         var urlhost = url.split("/");
  76.         var qhost = urlhost[2];
  77.         gTabId = tabId;
  78.  
  79.         if(state == 1) {// page loading
  80.             gFindIP =  plugin.getServerIp(qhost);
  81.             plugin.setStatusInfo("", gFindIP, "", gTabId);                    
  82.         }/* else if(state == 2) {// page loaded
  83.             gFindIP =  plugin.getServerIp(qhost);
  84.              gSIP = gFindIP.split(".");
  85.             gS1 = gSIP[0];
  86.             gS2 = gSIP[0] + gSIP[1];
  87.  
  88.             if(gS2 == "192168" || gS1 == "10") {
  89.                 gFindServer = "Intranet Site";
  90.                 processResult();
  91.                 return;
  92.             }
  93.             if(plugin.getTabValue(tabId,"serverinfo_oldip") != gFindIP) {
  94.                 reqObj.request(processFindServerData, tabId, url, "User-Agent", "Mozilla/4.0 (compatible; Windows XP 5.1)","HEAD");
  95.             }else{
  96.                 gFindServer = plugin.getTabValue(tabId,"serverinfo_oldserver");
  97.                 processResult();
  98.             }
  99.         }*/
  100.     }
  101.  
  102. /*
  103.     function processFindServerData(req, tabId) {
  104.         var lastm = req.getResponseHeader('Last-Modified');
  105.         var webserver = req.getResponseHeader('Server');
  106.         
  107.         if(gTabId == tabId) {
  108.             var FindServer = "<b>Web Server:</b> " + webserver + "<br><b>Last Modified:</b> " + lastm;
  109.             gFindServer = FindServer;
  110.             plugin.setTabValue(tabId,"serverinfo_oldserver",gFindServer);
  111.             plugin.setTabValue(tabId,"serverinfo_oldip",gFindIP);
  112.             processResult();
  113.         }else{
  114.         }
  115.     }
  116.  
  117.     function processResult()
  118.     {
  119.         var tips = gFindServer + "<br><b>IP:</b> " + gFindIP;
  120.         plugin.setStatusInfo("", gFindIP, tips, gTabId);
  121.     }
  122. */
  123. }
  124. )();
  125.  
  126.  
  127.